package com.cloud.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.cloud.consumer.service.SayHelloService;
@RestController
@RequestMapping("/consumerController")
public class ConsumerController {
	@Autowired
	private RestTemplate restTemplate;
	@Autowired
	private SayHelloService sayHelloService;
	/**
	 * provider为service_id
	 * @return
	 */
	@GetMapping("/helloConsumer")
	public String helloConsumer(){
		
		return restTemplate.getForEntity("http://provider/helloController/sayHelloWorld",
						String.class).getBody();
	}
	@GetMapping("/helloConsumer2")
	public String helloConsumer2(){
		
		return sayHelloService.sayHello();
	}
}
